#!/usr/bin/env python3
# -*- coding: utf-8 -*-
"""
模型准确性测试脚本
"""

import sys
import os
sys.path.append(os.path.dirname(os.path.abspath(__file__)))
from wechat_parser import auto_categorize

if __name__ == "__main__":
    # 测试数据集和预期结果
    test_cases = [
        ("星巴克咖啡", ("餐饮", "咖啡")),
        ("地铁出行", ("交通", "公共交通")),
        ("超市购物", ("购物", "日用品")),
        ("电影票", ("娱乐", "电影")),
        ("医院挂号", ("医疗", "门诊")),
        ("在线课程", ("教育", "在线教育")),
        ("房租支付", ("生活缴费", "房租")),
        ("水电费", ("生活缴费", "水电费")),
        ("外卖订单", ("餐饮", "外卖")),
        ("滴滴出行", ("交通", "打车")),
        ("京东购物", ("购物", "电子产品")),
        ("其他消费", ("其他", "其他")),
        ("肯德基快餐", ("餐饮", "快餐")),
        ("公交卡充值", ("交通", "公共交通")),
        ("淘宝购物", ("购物", "服饰")),
        ("游戏充值", ("娱乐", "游戏")),
        ("体检费用", ("医疗", "体检")),
        ("培训课程", ("教育", "培训")),
        ("物业费", ("生活缴费", "物业费")),
        ("燃气费", ("生活缴费", "燃气费"))
    ]
    
    # 准确性测试
    correct_predictions = 0
    total_predictions = len(test_cases)
    
    print("模型准确性测试结果:")
    for case, expected in test_cases:
        result = auto_categorize(case)
        if result == expected:
            correct_predictions += 1
            status = "✓"
        else:
            status = "✗"
        print(f"{status} '{case}' -> 预期: {expected}, 实际: {result}")
    
    accuracy = correct_predictions / total_predictions * 100
    print(f"\n准确率: {correct_predictions}/{total_predictions} ({accuracy:.2f}%)")